package com.fxz.common.lang;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {

    private int code;

    private String msg;

    private T data;

    public static <T> Result<T> succ(T data) {
        return succ(200, "操作成功!", data);
    }

    public static <T> Result<T> succ(int code, String msg, T data) {
        Result r = new Result();
        r.setCode(200);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }


    public static <T> Result<T> fail(String msg) {
        return fail(400, msg, null);
    }

    public static <T> Result<T> fail(int code, String msg, T data) {
        Result r = new Result();
        r.setCode(400);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
}
